package com.ecloud.gardensterminal.controller;

import com.ecloud.gardensterminal.common.JsonResult;
import com.ecloud.gardensterminal.controller.dto.GardensMqttCallback;
import com.ecloud.gardensterminal.controller.dto.GardensMqttSwitchDto;
import com.ecloud.gardensterminal.server.MqttService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Squbi
 */
@RestController
public class MqttController {
    @Autowired
    private MqttService service;

    @PostMapping("/mqtt/switch")
    public JsonResult localSwitch(@RequestBody GardensMqttSwitchDto dto) {
        service.sendSwitch(dto.getDeviceId(), dto.getOperation());
        return JsonResult.success();
    }
}
